package com.kang.workqueue;

import com.kang.utils.RabbitMQUtils;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.MessageProperties;

import java.io.IOException;

public class Provider {

    public static void main(String[] args) throws IOException {
        //获取连接对象
        Connection connection = RabbitMQUtils.getConnection();
        //获取通道队列
        Channel channel = connection.createChannel();

        //通过通道声明队列
        channel.queueDeclare("work",true,false,false,null);
        for (int i = 0; i < 10; i++) {
            //生产消息
            channel.basicPublish("","work", MessageProperties.PERSISTENT_TEXT_PLAIN,"hello work queue".getBytes());
        }
        //释放资源
        RabbitMQUtils.closeConnectionAndChanel(channel,connection);
    }
}
